module Mi
  class Model
    class Sql
      @@LOGGING_DB="gold_logging"
      @@GOLD_DB="gold"
      @@GOLD_LOGGING="gold_log"
      @@GOLD_TB_BUYER_ORDERS="tb_buyer_orders"
      @@GOLD_TB_SELLER_ORDERS="tb_seller_orders"
      def self.info_gold_logging app,level,memo
        sqlstr="insert into #{@@LOGGING_DB}.#{@@GOLD_LOGGING}(created_at,updated_at,app,level,memo)  values(now(),now(),'#{app}','#{level}','#{memo}')"
        return sqlstr
      end
      #获得买家最近一次更新的快递信息
      def self.last_buyer_order user_id
        sqlstr="select * from #{@@GOLD_DB}.#{@@GOLD_TB_BUYER_ORDERS} where user_id=#{user_id} and is_newer=1 order by updated_at desc limit 1"
        return sqlstr
      end
      #获得賣家最近一次更新的快递信息
      def self.last_seller_order user_id
        sqlstr="select * from #{@@GOLD_DB}.#{@@GOLD_TB_SELLER_ORDERS} where user_id=#{user_id} and is_newer=1 order by updated_at desc limit 1"
        return sqlstr
      end
    end
  end
end
